<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        function f() {
//document.getElementsByTagName("input");是按照指定标签名来进行查询并返回集合
//这个集合的操作跟数组一样，集合中都是dom对象
var elementsByTagName = document.getElementsByTagName("input");

for(var i=0;i<elementsByTagName.length;i++){
    elementsByTagName[i].checked=true;

}

        }
    </script>
</head>
<body>
选择：<input type="checkbox" value="java"checked="checked">Java
<input type="checkbox" value="PHP">PHP
<input type="checkbox" value="Python">Python
<button onclick="f()">全选</button>

</body>
</html>